<template>
  <view v-if="!isWebsite" class="index">
    结果是：{{ content }}
  </view>
  <web-view v-else :src="content"></web-view>
</template>

<script>
import { ref } from "vue"
import Taro from "@tarojs/taro";

export default {
  name: "index",
  setup() {
    const isWebsite = ref(false)
    const content = ref("")
    const router = Taro.getCurrentInstance().router
    let { result = "" } = router.params
    result = decodeURIComponent(result)
    content.value = result
    isWebsite.value = (result.startsWith("http://") || /^https:\/\//.test(result))
    /*
    if (result.startsWith("http://") || /^https:\/\//.test(result)) {
      isWebsite.value = true
    } else {
      isWebsite.value = false
    }*/

    return {
      content,
      isWebsite
    }
  }
}
</script>
